/*
 * @Description: 
 * @Autor: 商晓彬
 * @Date: 2021-05-27 17:48:34
 * @LastEditors: 商晓彬
 * @LastEditTime: 2021-12-24 14:37:08
 */
import { AfterViewChecked, Component, ElementRef, EventEmitter, Injector, Input, Output, ViewChild } from '@angular/core';
import { AppComponentBase } from '@shared/common/app-component-base';
import { TechProcessServiceProxy } from '@shared/service-proxies/service-proxies';
import { ModalDirective } from 'ngx-bootstrap';
import * as _ from 'lodash';
import { finalize } from 'rxjs/operators';
import { MessageService } from '@abp/message/message.service';

@Component({
    selector: 'app-search',
    templateUrl: './search.component.html',
    styleUrls: ['./search.component.less']
})
export class SearchComponent extends AppComponentBase {

    constructor(injector: Injector,
        private _messageService: MessageService,
        private _importService: TechProcessServiceProxy) {
        super(injector);
    }
    @ViewChild('createOrEditModal') modal: ModalDirective;
    @Output() modalSave: EventEmitter<any> = new EventEmitter<any>();
    //父组件传参
    @Input() parentInfo: any;
    active = false;
    //查看新增任务
    show(): void {
        this.active = true;
        this.modal.show();
    }
    //关闭事件
    close(): void {
        this.active = false;
        this.modal.hide();
    }
    // 导入
    import() {
        abp.ui.setBusy(undefined, '', 1);
        this._importService.createTechInfoFromUrl(
            this.parentInfo.codeId,
        ).pipe(finalize(() => { })).subscribe(result => {
            abp.ui.clearBusy();
            this._messageService.success('导入成功！');
            this.modalSave.emit();
            this.close();
        });
    }
    onShown() {

    }
    ngOnInit() {
    }

}
